package com.vhall.component.controller.goods;

import com.vhall.component.entity.goods.dto.GuoPrdInfoDTO;
import com.vhall.component.entity.goods.dto.GuoXinPrdInfoDTO;
import com.vhall.component.entity.goods.goods.GoodsStatisVO;
import com.vhall.component.entity.goods.vo.GetGoodsInfoRequestVO;
import com.vhall.component.entity.goods.vo.GetGoodsInfoResponseVO;
import com.vhall.component.entity.goods.vo.SearchGoodsPageRequestVO;
import com.vhall.component.entity.goods.vo.SearchGoodsResponseVO;
import com.vhall.component.entity.page.vo.PageVO;
import com.vhall.component.plugin.common.annotation.TokenAuth;
import com.vhall.component.service.goods.GuoxinPrdService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 国信产品关联接口
 *
 * @author xing.wang
 * @date 2023/8/22
 */
@RestController
@RequestMapping("/v4/goods/console/guoxin")
public class GuoXinGoodsController {
    @Resource
    private GuoxinPrdService guoxinPrdService;

    /**
     * 关联国信产品列表的查询
     *
     * @param vo
     * @return
     */
    @TokenAuth
    @GetMapping("/goods-page")
    public PageVO<SearchGoodsResponseVO> searchGoodsPage(@Validated SearchGoodsPageRequestVO vo) {
        return guoxinPrdService.searchGoodsPage(vo);
    }

    /**
     * 查询房间的关联商品列表
     *
     * @param ilId     房间主键ID
     * @param pageNum  页数
     * @param pageSize 页大小
     * @return
     */
    @TokenAuth
    @GetMapping("/room/goods")
    public PageVO<SearchGoodsResponseVO> findRoomGoodsPage(@RequestParam("il_id") Integer ilId,
                                                           @RequestParam("page") int pageNum,
                                                           @RequestParam("page_size") int pageSize) {
        return guoxinPrdService.searchRoomGoods(ilId, pageNum, pageSize);
    }

    /**
     * 根据国信产品编号,获取国信信息
     * 可以传入多个国信产品编号
     *
     * @param vo
     * @return
     */
    @TokenAuth
    @GetMapping("/goods-info")
    public List<GetGoodsInfoResponseVO> getGoodsInfoList(@Validated GetGoodsInfoRequestVO vo) {
        return guoxinPrdService.getGoodsInfoList(vo);
    }

    /**
     * 保存房间关联的商品
     *
     * @param dto
     * @return
     */
    @TokenAuth
    @PostMapping("/add/room-goods")
    public Boolean saveRoomGoods(@RequestBody @Validated GuoXinPrdInfoDTO dto) {
        return guoxinPrdService.saveRoomGoods(dto);
    }

    /**
     * 删除房间关联商品
     *
     * @param dto
     * @return
     */
    @TokenAuth
    @PostMapping("/del/room-goods")
    public Boolean delRoomGoods(GuoPrdInfoDTO dto) {
        return guoxinPrdService.delRoomGoods(dto);
    }

    /**
     * 直播数据--商品数据
     *
     * @param ilId
     * @return
     */
    @TokenAuth
    @GetMapping("/room-goods/data")
    public PageVO<GoodsStatisVO> getGoodsStatis(@RequestParam(value = "il_id") Integer ilId,
                                              @RequestParam(value = "page") Integer page,
                                              @RequestParam(value = "page_size") Integer pageSize) {
        return guoxinPrdService.getGoodsStatis(ilId, page, pageSize);
    }
}
